<!DOCTYPE html>
<html class="iframe-h">

	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css" />
	</head>

	<body>
		<div class="wrap-container clearfix">
				<div class="column-content-detail">
					<form class="layui-form" action="">
						<div class="layui-form-item">
							<div class="layui-inline tool-btn">
								<button class="layui-btn layui-btn-small layui-btn-normal addBtn" data-url="data_add"><i class="layui-icon">数据导入</i></button>
								<button class="layui-btn layui-btn-small layui-btn-normal addBtn" data-url="/excel_change">excel格式转换</button>
								<button class="layui-btn layui-btn-small layui-btn-danger delBtn"  data-url="article-add.html"><i class="layui-icon">&#xe640;</i></button>
								<!-- <button class="layui-btn layui-btn-small layui-btn-warm listOrderBtn hidden-xs" data-url="article-add.html"><i class="iconfont">&#xe656;</i></button> -->
							</div>
						</div>
					</form>
					<div class="layui-form" id="table-list">
						<table class="layui-table" lay-even lay-skin="nob">
							<colgroup>
								<col>
								<col>
								<col>
								<col>
								<col>
								<col>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
									<th>id</th>
									<th>数据名称</th>
									<th>包含地区</th>
									<th>时间范围</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
						<div class="page-wrap">
							<ul class="pagination">
								<li class="disabled"><span>«</span></li>
								<li class="active"><span>1</span></li>
								<li>
									<a href="#">»</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
		</div>
		<script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script>
			layui.use(['jquery','layer','dialog'], function() {
				var $ = layui.jquery,
				layer = layui.layer,
				dialog = layui.dialog;
				$.post("/getList",function(res){
					if(res.code > 0){
						var data = res.dataList;
						var _html = '';
						for(var i in data){
							_html += `<tr>
								<td><input type="checkbox" name="" lay-skin="primary" data-id="1"></td>
								<td>${data[i].id}</td>
								<td>${data[i].title}</td>
								<td>`;
								var detault = '';
								for(var j in data[i].data){
									if(detault == ''){
										detault = j;
									}
									_html += `${j},`
								}
								_html += `</td>
								<td class="hidden-xs">${data[i].dateList[0]}至${data[i].dateList[data[i].dateList.length-1]}</td>
								<td>${data[i].addtime}</td>
								<td>
									<div class="layui-inline">
										<button data-id="${data[i].title}" class="layui-btn layui-btn-small layui-btn-normal go-btn" data-url="/echarts/${data[i].title}">生成图表</button>
										<button data-id="${data[i].title}" class="layui-btn layui-btn-small layui-btn-normal go-btn" data-url="/data_list/${data[i].title}/${detault}/0/1">数据详情</button>
										<button class="layui-btn layui-btn-small layui-btn-danger del-btn" title="${data[i].title}" data-url="article-detail.html"><i class="layui-icon">&#xe640;</i></button>
									</div>
								</td>
							</tr>`;
						}
						$('#table-list table').find('tbody').html(_html)
					}
				},'json')
				$('#table-list').on('click', '.del-btn', function() {
					var url=$(this).attr('data-url');
					var title = $(this).attr('title');
					dialog.confirm({
						message:'您确定要进行删除吗？',
						success:function(){
							$.post('/data_del/'+title,{title:title},function(res){
								if(res.code > 0){
									layer.msg('删除成功');
									setTimeout(()=>{
										location.reload();
									},1000)
								}
							},'json');
						},
						cancel:function(){
						}
					})
					return false;
				})
			})
		</script>
	</body>

</html>